Garmin, GDB: Add 'bitscategory' options to allow specifying > 1 category at a time.
authorrobertl <robertl>
Sun, 6 Apr 2008 03:41:10 +0000 (03:41 +0000)
committerrobertl <robertl>
Sun, 6 Apr 2008 03:41:10 +0000 (03:41 +0000)
garmin.c
gdb.c
xmldoc/formats/options/garmin-bitscategory.xml [new file with mode: 0644]
xmldoc/formats/options/gdb-bitscategory.xml [new file with mode: 0644]

index 81a95675bf4c6de67f2b878df414ccf36989188f..7ee0126cf96c278f4b2a67a931c9bc00910fb440 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -43,6 +43,8 @@ static char *snlen = NULL;
 static char *snwhiteopt = NULL;
 static char *deficon = NULL;
 static char *category = NULL;
+static char *categorybitsopt = NULL;
+static int categorybits;
 
 #define MILITANT_VALID_WAYPT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
 
@@ -64,6 +66,8 @@ arglist_t garmin_args[] = {
                NULL, ARGTYPE_BOOL, ARG_NOMINMAX},
        { "category", &category, "Category number to use for written waypoints", 
                NULL, ARGTYPE_INT, "1", "16"},
+       { "bitscategory", &categorybitsopt, "Bitmap of categories", 
+               NULL, ARGTYPE_INT, "1", "65535"},
        ARG_TERMINATOR
 };
 
@@ -104,6 +108,10 @@ rw_init(const char *fname)
                return;
        }
 
+       if (categorybitsopt) {
+               categorybits = strtol(categorybitsopt, NULL, 0);
+       }
+
         if (GPS_Init(fname) < 0) {
                fatal(MYNAME ":Can't init %s\n", fname);
        }
@@ -232,6 +240,8 @@ rw_init(const char *fname)
 
        if (receiver_charset)
                cet_convert_init(receiver_charset, 1);
+
+
 }
 
 static void
@@ -809,6 +819,9 @@ xasprintf(&src, "%s %s", &wpt->shortname[2], src);
                if (category) {
                        way[i]->category = 1 << (atoi(category) - 1);
                }
+               if (categorybits) {
+                       way[i]->category = categorybits;
+               }
 #if SOON
                garmin_fs_garmin_before_write(wpt, way[i], gps_waypt_type);
 #endif
diff --git a/gdb.c b/gdb.c
index 8a42931c96a44fc2e100eb9221c60c4380836482..96ea27c0bb30241946e9b0653a7c99d67bfd32c8 100644 (file)
--- a/gdb.c
+++ b/gdb.c
 
 /*******************************************************************************/
 
-/* static char gdb_release[] = "$Revision: 1.61 $"; */
-static char gdb_release_date[] = "$Date: 2008/01/09 23:06:04 $";
+/* static char gdb_release[] = "$Revision: 1.62 $"; */
+static char gdb_release_date[] = "$Date: 2008/04/06 03:41:10 $";
 
 static gbfile *fin, *fout;
 static int gdb_ver, gdb_category, gdb_via, gdb_roadbook;
@@ -120,6 +120,7 @@ static char *gdb_opt_category;
 static char *gdb_opt_ver;
 static char *gdb_opt_via;
 static char *gdb_opt_roadbook;
+static char *gdb_opt_bitcategory;
 
 static int waypt_flag;
 static int route_flag;
@@ -1635,6 +1636,11 @@ init_writer(const char *fname)
                        MYNAME ": cat must be between 1 and 16!");
                gdb_category = 1 << (gdb_category - 1);
        }
+
+       if (gdb_opt_bitcategory) {
+               gdb_category = strtol(gdb_opt_bitcategory, NULL, 0);
+       }
+
        if (gdb_ver >= GDB_VER_UTF8)
                cet_convert_init(CET_CHARSET_UTF8, 1);
        
@@ -1686,12 +1692,15 @@ write_data(void)
 #define GDB_OPT_VER            "ver"
 #define GDB_OPT_VIA            "via"
 #define GDB_OPT_CATEGORY       "cat"
+#define GDB_OPT_BITCATEGORY    "bitcategory"
 #define GDB_OPT_ROADBOOK       "roadbook"
 
 static arglist_t gdb_args[] = {
        {GDB_OPT_CATEGORY, &gdb_opt_category,
                "Default category on output (1..16)", 
                NULL, ARGTYPE_INT, "1", "16"},
+        {GDB_OPT_BITCATEGORY, &gdb_opt_bitcategory, "Bitmap of categories",
+                NULL, ARGTYPE_INT, "1", "65535"},
        {GDB_OPT_VER, &gdb_opt_ver, 
                "Version of gdb file to generate (1..3)",
                "2", ARGTYPE_INT, "1", "3"},
@@ -1701,6 +1710,7 @@ static arglist_t gdb_args[] = {
        {GDB_OPT_ROADBOOK, &gdb_opt_roadbook,
                "Include major turn points (with description) from calculated route",
                NULL, ARGTYPE_BOOL, ARG_NOMINMAX},
+
        ARG_TERMINATOR
 };
 
diff --git a/xmldoc/formats/options/garmin-bitscategory.xml b/xmldoc/formats/options/garmin-bitscategory.xml
new file mode 100644 (file)
index 0000000..5b2c8d6
--- /dev/null
@@ -0,0 +1,19 @@
+<para>
+ This option is closely related to the 'category' option.  While category 
+ allows you to choose a single category that waypoints should appear in,
+ this options allows you to specify a bitmask to be used for the category.
+ Options may be specified in either decimal or hex.
+</para>
+<example id="garmin_bitcategory">
+  <title>Example for garmin bitcategory option to put all waypoints in categories 1 and 16.</title>
+<para>
+  The following two commands are equivalent.  They place a the point in both the first and last of the sixteen available categories.
+  <userinput>
+        gpsbabel -i gpx -f PocketQuery.gpx -o garmin,bitcategory=32769 -F usb:
+  </userinput>
+  <userinput>
+        gpsbabel -i gpx -f PocketQuery.gpx -o garmin,bitcategory=0x8001 -F usb:
+  </userinput>
+  
+</para>
+</example>
diff --git a/xmldoc/formats/options/gdb-bitscategory.xml b/xmldoc/formats/options/gdb-bitscategory.xml
new file mode 100644 (file)
index 0000000..18bf952
--- /dev/null
@@ -0,0 +1,19 @@
+<para>
+ This option is closely related to the 'category' option.  While category 
+ allows you to choose a single category that waypoints should appear in,
+ this options allows you to specify a bitmask to be used for the category.
+ Options may be specified in either decimal or hex.
+</para>
+<example id="gdb_bitcategory">
+  <title>Example for gdb bitcategory option to put all waypoints in categories 1 and 16.</title>
+<para>
+  The following two commands are equivalent.  They place a the point in both the first and last of the sixteen available categories.
+  <userinput>
+        gpsbabel -i gpx -f PocketQuery.gpx -o gdb,bitcategory=32769 -F foo.gdb
+  </userinput>
+  <userinput>
+        gpsbabel -i gpx -f PocketQuery.gpx -o gdb,bitcategory=0x8001 -F foo.gdb
+  </userinput>
+  
+</para>
+</example>